clear			all
set 			more off
cd 				"~/Dropbox/Indonesia Migration/" // Specify your root directory here
/*******************************************************************************
********************************************************************************/
use				"Data/Merged", clear
label 			var per_immig_cst_5Y "Population share of new migrants in year t"
label 			var per_immig_cst_5Y_lag "Population share of new migrants in year t-5"

foreach 		var in wage native_wage mig_wage_o mig_wage_n ///
				SE native_SE mig_SE_o mig_SE_n ///
				unpaid native_unpaid mig_unpaid_o mig_unpaid_n {
replace			prop_`var' = prop_`var' * 100
}

/*******************************************************************************
				Wage employment
********************************************************************************/
quietly ivreg2	prop_wage (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p1
				
quietly ivreg2	prop_native_wage (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p2
				
quietly ivreg2	prop_mig_wage_o (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p3

quietly ivreg2	prop_mig_wage_n (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p4

coefplot (p1, keep(per_immig_cst_5Y) mcolor(black) offset(-2.6) ciopts(recast(rcap) lcolor(black))) ///
(p1, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-3.4) ciopts(recast(rcap) lcolor(navy))) ///
(p2, keep(per_immig_cst_5Y) mcolor(black) offset(-1.6) ciopts(recast(rcap) lcolor(black))) ///
(p2, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-2.4) ciopts(recast(rcap) lcolor(navy))) ///
(p3, keep(per_immig_cst_5Y) mcolor(black) offset(-0.6) ciopts(recast(rcap) lcolor(black))) ///
(p3, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-1.4) ciopts(recast(rcap) lcolor(navy))) ///
(p4, keep(per_immig_cst_5Y) mcolor(black) offset(0.6) ciopts(recast(rcap) lcolor(black))) ///
(p4, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-0.2) ciopts(recast(rcap) lcolor(navy))), ///
vertical yline(0, lpattern (dash) lcolor(red)) scheme(s1color) /// 
xlabel(-1.5 `" "All" "People" "' -0.5 "Natives" 0.5 `" "Old" "Migrants" "' 1.5 `" "New" "Migrants" "', /// 
noticks labsize(small)) title("{bf:Panel A:} Impact of internal migration on wage employment", size(small)) xsize(12) ysize(8) /// 
xtitle("Multiple instruments using {it:t-10} migration settlement", size(small)) ///
legend(order(2 "Share of new migrants in year {it:t}" 4 "Share of new migrants in year {it:t-5}")) /// 
graphregion(margin(2 4 2 2)) xscale(r(-2 2) noextend titlegap(2)) yscale(titlegap(2))

graph export "Coefplots/T6_wage_mt10.jpg", as(jpg) name("Graph") quality(100) replace
				
/*******************************************************************************
				Self employment
********************************************************************************/
quietly ivreg2	prop_SE (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p1
				
quietly ivreg2	prop_native_SE (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p2
				
quietly ivreg2	prop_mig_SE_o (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p3

quietly ivreg2	prop_mig_SE_n (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p4

coefplot (p1, keep(per_immig_cst_5Y) mcolor(black) offset(-2.6) ciopts(recast(rcap) lcolor(black))) ///
(p1, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-3.4) ciopts(recast(rcap) lcolor(navy))) ///
(p2, keep(per_immig_cst_5Y) mcolor(black) offset(-1.6) ciopts(recast(rcap) lcolor(black))) ///
(p2, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-2.4) ciopts(recast(rcap) lcolor(navy))) ///
(p3, keep(per_immig_cst_5Y) mcolor(black) offset(-0.6) ciopts(recast(rcap) lcolor(black))) ///
(p3, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-1.4) ciopts(recast(rcap) lcolor(navy))) ///
(p4, keep(per_immig_cst_5Y) mcolor(black) offset(0.6) ciopts(recast(rcap) lcolor(black))) ///
(p4, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-0.2) ciopts(recast(rcap) lcolor(navy))), ///
vertical yline(0, lpattern (dash) lcolor(red)) scheme(s1color) /// 
xlabel(-1.5 `" "All" "People" "' -0.5 "Natives" 0.5 `" "Old" "Migrants" "' 1.5 `" "New" "Migrants" "', /// 
noticks labsize(small)) title("{bf:Panel B:} Impact of internal migration on self employment", size(small)) xsize(12) ysize(8) /// 
xtitle("Multiple instruments using {it:t-10} migration settlement", size(small)) ///
legend(order(2 "Share of new migrants in year {it:t}" 4 "Share of new migrants in year {it:t-5}")) /// 
graphregion(margin(2 4 2 2)) xscale(r(-2 2) noextend titlegap(2)) yscale(titlegap(2))

graph export "Coefplots/T6_self_mt10.jpg", as(jpg) name("Graph") quality(100) replace
				
/*******************************************************************************
				Unpaid work
********************************************************************************/
quietly ivreg2	prop_unpaid (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p1
				
quietly ivreg2	prop_native_unpaid (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p2
				
quietly ivreg2	prop_mig_unpaid_o (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p3

quietly ivreg2	prop_mig_unpaid_n (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p4

coefplot (p1, keep(per_immig_cst_5Y) mcolor(black) offset(-2.6) ciopts(recast(rcap) lcolor(black))) ///
(p1, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-3.4) ciopts(recast(rcap) lcolor(navy))) ///
(p2, keep(per_immig_cst_5Y) mcolor(black) offset(-1.6) ciopts(recast(rcap) lcolor(black))) ///
(p2, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-2.4) ciopts(recast(rcap) lcolor(navy))) ///
(p3, keep(per_immig_cst_5Y) mcolor(black) offset(-0.6) ciopts(recast(rcap) lcolor(black))) ///
(p3, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-1.4) ciopts(recast(rcap) lcolor(navy))) ///
(p4, keep(per_immig_cst_5Y) mcolor(black) offset(0.6) ciopts(recast(rcap) lcolor(black))) ///
(p4, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-0.2) ciopts(recast(rcap) lcolor(navy))), ///
vertical yline(0, lpattern (dash) lcolor(red)) scheme(s1color) /// 
xlabel(-1.5 `" "All" "People" "' -0.5 "Natives" 0.5 `" "Old" "Migrants" "' 1.5 `" "New" "Migrants" "', /// 
noticks labsize(small)) title("{bf:Panel C:} Impact of internal migration on unpaid work", size(small)) xsize(12) ysize(8) /// 
xtitle("Multiple instruments using {it:t-10} migration settlement", size(small)) ///
legend(order(2 "Share of new migrants in year {it:t}" 4 "Share of new migrants in year {it:t-5}")) /// 
graphregion(margin(2 4 2 2)) xscale(r(-2 2) noextend titlegap(2)) yscale(titlegap(2))

graph export "Coefplots/T6_unpaid_mt10.jpg", as(jpg) name("Graph") quality(100) replace
